[IOEMU] Process reset requests before returning control to the guest.
authorIan Campbell <ian.campbell@xensource.com>
Wed, 3 Jan 2007 13:55:53 +0000 (13:55 +0000)
committerIan Campbell <ian.campbell@xensource.com>
Wed, 3 Jan 2007 13:55:53 +0000 (13:55 +0000)
Since 12899:4ae4bdee00e Xen only pays attention the first shutdown or
reboot request for a domain.

When a reset if requested we need to make the SCHEDOP_remote_shutdown
hypercall before we return control to the guest so that it wins the
"race" with the heuristic in xen/arch/x86/hvm/hvm.c:hvm_vcpu_down()
which causes a powerdown.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
tools/ioemu/target-i386-dm/helper2.c

index aa7b042561234c77aecf4450c7e6c454010f879b..ae84b9ed232f234890ef0420ec43581e3a5bf388 100644 (file)
@@ -498,6 +498,8 @@ void handle_buffered_io(void *opaque)
 
 void cpu_handle_ioreq(void *opaque)
 {
+    extern int vm_running;
+    extern int shutdown_requested;
     CPUState *env = opaque;
     ioreq_t *req = cpu_get_ioreq();
 
@@ -516,6 +518,25 @@ void cpu_handle_ioreq(void *opaque)
         }
 
         wmb(); /* Update ioreq contents /then/ update state. */
+
+       /*
+         * We do this before we send the response so that the tools
+         * have the opportunity to pick up on the reset before the
+         * guest resumes and does a hlt with interrupts disabled which
+         * causes Xen to powerdown the domain.
+         */
+        if (vm_running) {
+            if (shutdown_requested) {
+               fprintf(logfile, "shutdown requested in cpu_handle_ioreq\n");
+               destroy_hvm_domain();
+           }
+           if (reset_requested) {
+               fprintf(logfile, "reset requested in cpu_handle_ioreq.\n");
+               qemu_system_reset();
+               reset_requested = 0;
+           }
+       }
+
         req->state = STATE_IORESP_READY;
         xc_evtchn_notify(xce_handle, ioreq_local_port[send_vcpu]);
     }